package com.blkkj.huan.Controller;

import com.aliyuncs.iot.model.v20170420.QueryApplyStatusRequest;
import com.aliyuncs.iot.model.v20170420.QueryApplyStatusResponse;
import com.blkkj.huan.util.BaseTest;
import com.blkkj.huan.util.LogUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class queryApplyStatusController extends BaseTest {

    @PostMapping("/queryApplyStatus")
    public String queryApplyStatus(Long applyId){
        //查询批量注册申请单状态
        queryApplyStatusTest(applyId);
        return "huan";
    }

    /**
     * 查询申请单是否执行完毕
     *
     * @param applyId 申请单id
     * @return 是否执行完毕
     */
    public static Boolean queryApplyStatusTest(Long applyId) {
        QueryApplyStatusRequest request = new QueryApplyStatusRequest();
        request.setApplyId(applyId);
        QueryApplyStatusResponse response = (QueryApplyStatusResponse)executeTest(request);
        if (response != null && response.getSuccess() != false) {
            LogUtil.print("查询申请单执行状态成功！ 是否执行完成: " + response.getFinish());
            return response.getFinish();
        } else {
            LogUtil.error("查询申请单执行状态失败！requestId:" + response.getRequestId() + "原因：" + response.getErrorMessage());

        }

        return null;
    }
}
